package com.xframe.domain;

import com.xframe.domain.role.IUserCredentials;

/**
 * 用户凭证线程管理器
 */
public class CredentialsContainer {
    /**
     * 线程对象
     */
    private static final ThreadLocal<IUserCredentials> container = new ThreadLocal<IUserCredentials>();

    /**
     * 添加一个用户凭证到线程对象中
     *
     * @param userCredentials 用户凭证
     */
    public static void addCredentials(IUserCredentials userCredentials){
        container.set(userCredentials);
    }
    /**
     * 获取一个用户凭证到线程对象中
     * @return IUserCredentials实现
     */
    public static IUserCredentials getCredentials(){
        return container.get();
    }

    /**
     * 移除用户凭证
     */
    public static void remove(){
        container.remove();
    }
}
